# Contributor: Jakub Jirutka <jakub@jirutka.cz>
# Maintainer: Jakub Jirutka <jakub@jirutka.cz>
# TODO: Fix to not compile .so lib twice (in build and test).
pkgname=ruby-escape_utils
_gemname=${pkgname#ruby-}
pkgver=1.2.1
pkgrel=6
pkgdesc="Faster string escaping routines for your Ruby apps"
url="https://github.com/brianmario/escape_utils"
arch="all"
license="MIT"
checkdepends="ruby ruby-bundler ruby-minitest ruby-rake-compiler"
makedepends="ruby-dev"
source="$pkgname-$pkgver.tar.gz::https://github.com/brianmario/escape_utils/archive/$pkgver.tar.gz
	gemspec.patch
	fix-tests-for-ruby-2.5.patch
	fix-tests-for-ruby-3.0.patch
	"
builddir="$srcdir/$_gemname-$pkgver"

build() {
	gem build $_gemname.gemspec
	gem install --local \
		--install-dir dist \
		--ignore-dependencies \
		--no-document \
		--verbose \
		$_gemname
}

check() {
	rake test
}

package() {
	local gemdir="$pkgdir/$(ruby -e 'puts Gem.default_dir')"
	cd "$builddir"/dist

	mkdir -p "$gemdir"
	cp -r extensions gems specifications "$gemdir"/

	# Remove unnecessary files.
	rm -r "$gemdir"/gems/$_gemname-$pkgver/ext
}

sha512sums="
c2af40a2a3c0cc083a55771e2ed813992391c833b6d64cb9255ec5741c2da6980ddf34331256b73f18617cf8df6b745e81bdd6c1632d63936ccd3a655758b083  ruby-escape_utils-1.2.1.tar.gz
8cb3c26b46304899b2d200208c18650ab28da81ea42d8479a89b06802d252757df537c997fe5f640122a4521016f0676c267c691bc6be33ce066fe4be0c504d5  gemspec.patch
06de5f7afcc3b7461d9e915d62ae0405d2161c37759c6868c9b550998995935b90e2865d30b1c9c9a0a5a474d96c5f94762114cda7b2c0b825717c8066115b62  fix-tests-for-ruby-2.5.patch
113482b5b3eee64c078d294159447f4d3fa8aa5e5963829fdc8090cab6c333541e78cbcd02299624b822e6663b8988cd56112d7d0802ecb854ee69c0d303426c  fix-tests-for-ruby-3.0.patch
"
